<?php 
if($dataProviderE->itemCount==0){
	echo '<div class="me-cannotplay"></div>';
}
else{
?>
<?php 
	$devide=Tools::checkDevice();
	$html='<video width="100%" height="auto" id="player1" src="" type="video/mp4" controls="controls"></video>';
	if($devide=='wap'){
		$html='<a title="play" class="player_video" href="#"><img src="'.Yii::app()->request->baseUrl.'/images/Play_50-1.png"/></a>';
	}
?>
<div class="clip_player"><?php echo $html;?></div>
<div class="warning_trans" style="display: none;">
	<p>Để xem tiếp phim <b><?php echo $model->title?></b>. Bạn vui lòng mua với giá: <b><?php echo $model->retail[0]['price'].' đồng.'?></b></p>
	<?php echo CHtml::link('Mua', array('/film/view', 'id'=>$model->id),array('title'=>$model->title,'class'=>'button-get'));?>
</div>
<?php 
$this->widget('zii.widgets.CListView', array(
    'dataProvider'=>$dataProviderE,
    'itemView'=>'_view',
	'summaryText'=>'',
	'htmlOptions'=>array(
		'class'=>'episode_list',
	),
	'pager' => array(
            'firstPageLabel'=>'Đầu',
            'prevPageLabel'=>'Trước',
            'nextPageLabel'=>'Tiếp',
            'lastPageLabel'=>'Cuối',
            'maxButtonCount'=>0,
     ),
     
));
?>
<script type="text/javascript">

var link='';
var i=0;
$('.link').removeAttr('id');
$('a.link').each(function(index){
	if(i==0){
		link=$(this).attr("data");
		$(this).attr('id','active');
	}
	i++;
});
<?php if($devide!='wap'):?>
$("#player1").attr("src",link);
<?php else:?>
$("a.player_video").attr("href",link);
<?php endif;?>
$('.link').click(function(){
	$('.link').removeAttr('id');
	$(this).attr('id','active');
	$('.clip_player').html('');
	if($(this).attr("data")!='#'){
		<?php if($devide!='wap'):?>
		$('.clip_player').html('<video width="100%" height="auto" id="player1" src="" type="video/mp4" controls="controls"></video>');
		$("#player1").attr("src",$(this).attr("data"));
		<?php else:?>
		$('.clip_player').html('<a class="player_video" href="#"><img src="<?php echo Yii::app()->request->baseUrl;?>/images/Play_50-1.png"/></a>');
		$("a.player_video").attr("href",$(this).attr("data"));
		<?php endif;?>
		<?php if($devide!='android' && $devide!='android2.1'):?>
		loadPlayer();
		<?php else:?>
		init();
		<?php endif;?>
	}else{
		$('.clip_player').html();
		$('.clip_player').css('display','none');
		$('.warning_trans').css('display','block');
	}
});

</script>
<?php
$js='';
				if($devide!='android' && $devide!='android2.1'){
					$js.= '<script type="text/javascript">'.
					  'function loadPlayer(){MediaElement("player1", {success: function(me) {'.
					    'me.play();'.
					    'me.addEventListener("timeupdate", function() {'.
					    'document.getElementById("time").innerHTML = me.currentTime;'.
						'}, false);'.
						'document.getElementById("pp")["onclick"] = function() {'.
						'if (me.paused){me.play();} else{me.pause();}};'.
					  '}});}
					  loadPlayer();
					  </script>';
				}
				else{
					$js.='<script type="text/javascript">'.
						'function init() {
					      enableVideoClicks();
					    }
					    function enableVideoClicks() {
					      var videos = document.getElementsByTagName("video") || [];
					      for (var i = 0; i < videos.length; i++) {
					        // TODO: use attachEvent in IE
					        videos[i].addEventListener("click", function(videoNode) {
					          return function() {
					            videoNode.play();
					          };
					        }(videos[i]));
					      }
					    }
					    init();
					    </script>';
				}
echo $js;
?>
<?php 
}
?>